package com.gouying.design.patterns.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class JDKProxyMain {

    public static void main(String[] args) {
        //ClassLoader loader,
        //Class<?>... interfaces
        JdkImpl jdk1 = new JdkImpl();
        JdkProxy jdkProxy = new JdkProxy(jdk1);
        Object jdk = Proxy.newProxyInstance(JdkImpl.class.getClassLoader(), JdkImpl.class.getInterfaces(), jdkProxy);
        System.out.println(jdk.getClass().getSimpleName());
        if(jdk instanceof JdkImpl){
            System.out.println("jdk");
        }else if (jdk instanceof JdkInterface){
            System.out.println("jdk interface");
            ((JdkInterface)jdk).sayHello();
        }
//        jdk.sayHello();

    }

}
